package cn.com.clearbus.bound;

import cn.com.clearbus.RedisApplication;
import cn.com.clearbus.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes={RedisApplication.class})// 指定启动类
public class BoundListOperations {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    RedisTemplate<String,Object> redisTemplate;

    @Test
    public void addUser(){
        String key = "user123";
        User cUser = new User();
        cUser.setUsername(key);
        Long aLong = redisTemplate.opsForList().leftPush(key, cUser);
        logger.info("想做插入对象信息为:{}",aLong);

    }
}
